/* 
#include<iostream>
#include<cstring>
using namespace std;
const int MAX = 10005;

int f[MAX][MAX];

int main() {
    memset(f, 0, sizeof(f));
    int n, x, y, a, b, g, k;
    cin >> n;
    for(int i=1; i<=n; i++) {
        cin >> a >> b >> g >> k;
        for(int j=a; j<=a+g; j++) {
            for(int l=b; l<=b+k; l++) {
                f[j][l] = i;
            }
        }
    }
    cin >> x >> y;
    if(f[x][y] == 0)  cout << "-1";
    else cout << f[x][y];
    return 0;
}
*/

// 防止MLE，既然已经知道了x y，可以先将数据存储，然后直接计算分析结果即可
#include<iostream>
#include<cstring>
using namespace std;
const int MAXN = 10005;

int main() {
    int n, x, y, a[MAXN], b[MAXN], g[MAXN], k[MAXN], ans = -1;
    cin >> n;
    for(int i=1; i<=n; i++) {
        cin >> a[i] >> b[i] >> g[i] >> k[i];
    }
    cin >> x >> y;
    for(int i=1; i<=n; i++) {
    	if(x>=a[i] && x<=a[i]+g[i] && y>=b[i] && y<=b[i]+k[i]) {
    		ans = i;
		}
	}
    cout << ans;
    return 0;
}